package com.peanut.service;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.peanut.domain.bo.TabUserBO;
import com.peanut.domain.po.TabUserPO;
import com.peanut.service.TabUserService;
import com.peanut.mapper.TabUserMapper;
import org.springframework.beans.BeanUtils;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

/**
* @author 张涛
* @description 针对表【tab_user】的数据库操作Service实现
* @createDate 2022-05-24 10:33:24
*/
@Service
class TabUserServiceImpl extends ServiceImpl<TabUserMapper, TabUserPO>
    implements TabUserService{

    @Resource
    private TabUserMapper userMapper;

    @Override
    public int userAdd(TabUserBO bo) {
        TabUserPO user = new TabUserPO();
        BeanUtils.copyProperties(bo,user);
        int insert = userMapper.insert(user);
        return insert;
    }

    @Override
    public Page<TabUserPO> findAll(Integer pageNumber, Integer pageSize) {
        Page<TabUserPO> user1 = new Page<>(pageNumber,pageSize);
        Page<TabUserPO> page = userMapper.selectPage(user1, null);
        return page;
    }

    @Override
    public int updateUser(TabUserBO bo) {
        TabUserPO user = new TabUserPO();
        BeanUtils.copyProperties(bo,user);
        int i = userMapper.updateById(user);
        return i;
    }

    @Override
    public int deleteUser(Long userId) {
        return userMapper.deleteById(userId);
    }
}




